package test;

import java.util.HashMap;

import people.Person.Name;
import people.professor.Professor;
import people.student.Student;
import people.student.StudentFactory;
import uniManager.UniManager;
import course.AbstractCourseType;
import course.Course;
import course.CourseFactory;
import course.SimpleTestType;
import course.group.Group;
import course.group.GroupCourseType;
import evaluation.CourseTypeEvaluation;

public class EvaluateStudentForGroup extends AbstractTestCase {
	private static final UniManager um = UniManager.INSTANCE;
	private static final StudentFactory sf = StudentFactory.INSTANCE;
	private static final CourseFactory cf = CourseFactory.INSTANCE;
	
	private Course c;
	private GroupCourseType gt;
	private Student s1, s2;
	private Professor professor;
	
	public void setUp() throws Exception {
		professor = new Professor(new Name("Walter", "Harz"));
		c = cf.createCourse("Eine LVA (VU) mit 2 Gruppen.", professor);
		um.addCourse(c);
		
		s1 = sf.addNewStudent(3111, new Name("Student3111", "jig"));
		s2 = sf.addNewStudent(3112, new Name("Student3112", "saw"));
		
		gt = new GroupCourseType(c.getCourseID(),"Haskell (Live) Arbeit", professor, null, null, null);
		
		um.addCourseType(c, gt);
	}
	
	public void tearDown() {
		
	}
	
	public void test() throws Exception {
		this.setUp();
		
		System.out.println("--------------------------------------");
		System.out.println("----Start of EvaluateStudentGroup-----");
		System.out.println("Register 2 Groups to GroupCourseType: ");
		gt.addGroup(1, "Montagsgruppe", professor);
		gt.addGroup(2, "Dienstagsgruppe", professor);
		System.out.println("Registered: 2 Groups ");
		System.out.println();
		
		HashMap<AbstractCourseType, Integer> options1 = new HashMap<AbstractCourseType, Integer>();
		HashMap<AbstractCourseType, Integer> options2 = new HashMap<AbstractCourseType, Integer>();
		
		System.out.println("Registration options for student s1:");
		for(AbstractCourseType t : c.getTypes()){
			System.out.println("Options for type "+t.getCourseName());
			for(String option : t.registrationOptions(s1)){
				System.out.println(option);
			}
			options1.put(t, 1);
		}
		
		System.out.println("Registration options for student s2:");
		for(AbstractCourseType t : c.getTypes()){
			System.out.println("Options for type "+t.getCourseName());
			for(String option : t.registrationOptions(s2)){
				System.out.println(option);
			}
			options2.put(t, 2);
		}
		System.out.println();
		
		System.out.println("Register Student 1 for Group 1");
		um.registerStudent(c, s1, options1);
		System.out.println("Registered: Student 1 for Group 1");
		
		System.out.println("Register Student 2 for Group 2");
		um.registerStudent(c, s2, options2);
		System.out.println("Registered: Student 1 for Group 2");
		System.out.println();
		
		System.out.println("--------------------------------------");
		System.out.println("Evaluating Student 1 and 2");
		System.out.println();
		

		
		System.out.println("Evaluate Students");
		System.out.println("Student 1 ["+s1.getMatrikelNr(s1)+"] with 80% for Eval 1 and 95% for Eval 2");
		um.evaluateStudent(gt, s1, 80);
		um.evaluateStudent(gt, s1, 95);
		System.out.println("Student 2 ["+s2.getMatrikelNr(s2)+"] with 61% for Eval 1 and 30% for Eval 2");
		um.evaluateStudent(gt, s2, 61);
		um.evaluateStudent(gt, s2, 30);
		System.out.println();
		
		System.out.println("Show Evaluations for Student 1:");
		for(CourseTypeEvaluation a : s1.getCourseTypeEvaluations(s1)) {
			System.out.println("  Course Type: Coures ID ["+a.getCourseType().getCourseID()+"]  Type ["+a.getCourseType().getCourseName()+"]  Rating: "+a.getGrade());
		}
		System.out.println();
		
		System.out.println("Show Evaluations for Student 2:");
		for(CourseTypeEvaluation a : s2.getCourseTypeEvaluations(s2)) {
			System.out.println("  Course Type: Coures ID ["+a.getCourseType().getCourseID()+"]  Type ["+a.getCourseType().getCourseName()+"]  Rating: "+a.getGrade());
		}
		System.out.println();
		
		System.out.println("End of EvaluatingStudentsGroup");
		System.out.println("--------------------------------------");
		this.tearDown();
	}

}
